﻿<%@ Page Language="c#" Inherits="WinnerCMS.WebUI.Admin.Index" CodeBehind="Index.aspx.cs"
    EnableViewState="False" %>

<%@ Import Namespace="WinnerCMS.BLL" %>

<!DOCTYPE>
<html>
<head id="Head1" runat="server">
    <meta charset="utf-8" />
    <title>WinnerCMS后台</title>
    <%: Scripts.Render("~/Scripts/AdminBase") %> 
    <%: Styles.Render("~/Content/Bootstrap/css") %>
    

    <style type="text/css">
        Body {
            font-size: 14px;
            margin: 0;
        }

        a {
            font-size: 14px;
        }

        .FrameWindow {
            height: 100%;
            width: 100%;
        }

        nav a {
            -ms-text-shadow: 0 0 0;
            text-shadow:  0 0 0;
        }
    </style>
    <script type="text/javascript">
        $(document).resize(function () { $('.easyui-tabs').tabs("resize"); });

        $(function () {
            NewTabPage('首页', 'Main.aspx');

            NavMenu($(".nav li").get(0));
        });

        function NavMenu(obj) {
            var id = $(obj).attr("datafld");
            $(".nav .active").removeClass("active");
            $(obj).addClass("active");

            if (id != "FED2B701-7295-47D9-8187-710D873463EA") {
                $('#tt').tree({
                    url: '/api/Menu/MenuData?id=' + id,
                    animate: true,
                    
                    onClick: function (node) {
                        if (node.attributes.url.length > 0) {
                                NewTabPage(node.text, node.attributes.url);
                        }

                        $('#tt').tree("toggle", node.target);
                    },
                    onLoadSuccess: function (node, data) {
                        if (data.length < 25) $('#tt').tree("collapseAll");
                    }
                });
            }
            else {
                $('#tt').tree({
                    url: '/api/Menu/GetTreeData?id='+id,
              
                    method: "get",
                    animate: true,
                    onClick: function (node) {
                        if (node.attributes.url.length > 0)
                            NewTabPage(node.text, node.attributes.url);

                        $('#tt').tree("toggle", node.target);
                    },
                    onLoadSuccess: function (node, data) {
                        if (data.length < 25)
                            $('#tt').tree("collapseAll");
                    }
                });
            }
        }
        function RefurbishTemplates() {
            $.ajax({
                type: "GET",
                url: "../AjaxPostBack.ashx?Action=RefurbishTemplates",
                success: function (msg) {
                    if (msg == "1") {
                        alert('刷新成功');
                    }
                    else {
                        alert('刷新失败');
                    }
                }
            });
        }
        function Exists() {
            $('.easyui-tabs').tabs('exists', title);
        }

        function ReName(oldName, newName) {

        }

        function NewTabPage(title, url) {
            if (!$('.easyui-tabs').tabs('exists', title)) {
                var aNewTab = $('.easyui-tabs').tabs('add', {
                    title: title,
                    content: $("<iframe id='fid'" + title + " src='" + url + "' class='FrameWindow' frameborder='0px' scrolling='yes'>"),
                    closable: true
                });

                $(".tabs-inner").dblclick(function () {
                    $('.easyui-tabs').tabs('close', title);
                });
                $(".tabs-inner").unbind('contextmenu');
                $(".tabs-inner").bind('contextmenu', function (e) {
                    $('#mm').menu('show', { left: e.pageX, top: e.pageY });
                    var subtitle = $(this).children("span:eq(0)").text();
                    $('#mm').data("currtab", subtitle);
                    return false;
                });
                tabCloseEven();
            }
            else {
                $('.easyui-tabs').tabs('close', title);
                var aNewTab = $('.easyui-tabs').tabs('add', {
                    title: title,
                    content: $("<iframe id='fid'" + title + " src='" + url + "' class='FrameWindow' frameborder='0px' scrolling='yes'>"),
                    closable: true
                });
                $('.easyui-tabs').tabs('select', title);

                var pp = $(".easyui-tabs").tabs('getSelected');
                var p = $(".easyui-tabs").tabs('getTab', pp.panel('options').title);
                if ($(p).find("iframe").attr('src') == url)
                { }
                else
                {
                    $(p).find("iframe").attr('src', url);
                    p.panel('refresh');
                }
            }
            return false;
        }
        function CloseTabPage(title) {
            $('.easyui-tabs').tabs('delete', title);
        }
        function CloseTab(title) {
            $('.easyui-tabs').tabs('close', title);
        }
        //绑定右键菜单事件
        function tabCloseEven() {
            //关闭当前
            $('#mm-tabclose').click(function () {
                var currtabTitle = $('#mm').data("currtab");
                $('.easyui-tabs').tabs('close', currtabTitle);
            });
            //全部关闭
            $('#mm-tabcloseall').click(function () {
                $('.tabs-inner span:eq(0)').each(function (i, n) {
                    var t = $(n).text();
                    $('.easyui-tabs').tabs('close', t);
                });
            });
        }

    </script>
</head>
<body class="easyui-layout">
    <div region="north" border="false" style="height: 104px;">
        <div class="header">
            <div style="padding-top: 8px; float: left; width: 280px; height: 32px; background: #ffffff url(Images/WinnerCMS.jpg) no-repeat;">
            </div>
            <div style="float: left; width: 87px; background-image: url(Images/top_1.jpg); height: 50px;">
            </div>
            <div style="float: left; width: 300px; color: #FFFFFF; font-weight: bold; text-align: center; background-image: url(Images/top_bg.jpg); height: 50px;">
                您好！<%= UserManage.Current.UserName %>，欢迎使用WinnerCMS V7
            </div>
            <div style="float: left; width: 31px; height: 50px; background-image: url(Images/top_2.jpg); font-weight: bold;">
            </div>
            <div style="float: right; padding-right: 30px;">
                <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/" Target="_blank" EnableViewState="false">网站首页</asp:HyperLink>
                <asp:HyperLink ID="HyperLink2" runat="server" Target="_blank" EnableViewState="false">修改密码</asp:HyperLink>
                <a href="http://blog.csdn.net/winner2050" target="_blank">作者博客</a><br />
                <a href="#" onclick="RefurbishTemplates();return false;">重建缓存</a> <a href="Logout.aspx"
                    target="_parent">注销登录</a> <a href="javascript:void(0)" onclick="window.open('about.aspx','','width=500,height=220,scrollbars=auto,resizable=yes,top=190,left=120');">关于我们</a>
            </div>
        </div>
        <nav class="navbar navbar-inverse" role="navigation" style="clear: both; margin-bottom: 0px;">
            <div class="collapse navbar-collapse">
                <ul class="nav navbar-nav">
                    <asp:Repeater ID="RP_Navlist" runat="server">
                        <ItemTemplate>
                            <li datafld='<%# Eval("ID") %>' class="active"><a href="javascript:void(0)" onclick="return NavMenu(this.parentNode);">
                                <%# Eval("Title") %></a></li>
                        </ItemTemplate>
                    </asp:Repeater>
                </ul>
            </div>
        </nav>
    </div>
    <div region="west" split="true" title="功能区" style="width: 200px;">
        <ul id="tt">
        </ul>
    </div>
    <div region="center" style="overflow: hidden;">
        <div class="easyui-tabs" fit="true" border="false">
        </div>
    </div>
    <div id="mm" class="easyui-menu" style="width: 150px;">
        <div id="mm-tabclose">
            关闭
        </div>
        <div id="mm-tabcloseall">
            全部关闭
        </div>
    </div>
</body>
</html>
